//
//  ViewController.m
//  MessageDynamicsDemo
//
//  Created by dayu on 15/5/26.
//  Copyright (c) 2015年 dayu. All rights reserved.
//

#import "ViewController.h"
#import "VVSpringCollectionViewFlowLayout.h"

@interface ViewController ()<UICollectionViewDataSource, UICollectionViewDelegate>
@property (nonatomic, strong) VVSpringCollectionViewFlowLayout *layout;
@end

static NSString *identifier = @"CollectionViewCell";
@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.layout = [[VVSpringCollectionViewFlowLayout alloc] init];
    self.layout.itemSize = CGSizeMake(self.view.frame.size.width, 44);
    UICollectionView *collectionView = [[UICollectionView alloc] initWithFrame:self.view.frame collectionViewLayout:self.layout];
    collectionView.backgroundColor = [UIColor clearColor];
    [collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:identifier];
    collectionView.dataSource = self;
    [self.view insertSubview:collectionView atIndex:0];
    
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return 50;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    
    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
    cell.backgroundColor = LYRandomColor;
    return cell;
}

@end
